﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Idlesoft.Utils;

namespace Idlesoft.ShellAnywhereLanguage
{
	public class ShellAction : IShellAction
	{
		public ShellAction(IVerb verb, ITarget target, params IParam[] paramz)
		{
			Verb = verb;
			Target = target;
			Params = paramz;
		}

		#region props
		public IVerb Verb { get; internal set; }
		public ITarget Target { get; internal set; }
		public IParam[] Params { get; internal set; }
		#endregion props

		#region methods
		public bool CanExecute
		{
			get { return Verb.CanExecute(Target); }
		}
		public void Execute()
		{
			if (CanExecute)
				Verb.Execute(Target, Params);
		}
		public override string ToString()
		{
			return "Verb={0} Target={1} Params=[{2}]".Format(Verb, Target, Params.Flatten("[", ",", "]") );
		}
		#endregion methods
	}
}
